package learnjava.basic.other;

public class Singleton{
    int a = 1; //对象初始化时执行，相当于不加static的构造代码段
    private Singleton(){};
    private static Singleton singleton = new Singleton(); //类初始化时就执行了,相当于加static的构造代码段
    public static Singleton getInstance(){
        return singleton;
    }
}

interface Single{
   void method1();
   int a = 0;
}